package com.wy2.controller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import javax.sound.midi.MidiDevice.Info;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.wy2.entity.Information;
import com.wy2.mapper.InformationMapper;
import com.wy2.service.InformationService;
import com.wy2.util.FenyeUtil;

@RestController
@RequestMapping("/Dynam")
@CrossOrigin
public class InformationController {

	@Autowired 
	private InformationService ds;
	
	@Autowired
	private InformationMapper im;
	//时间
	private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	/**
	 * 添加
	 * @param information
	 * @return
	 */
	@RequestMapping("/stuPush")
	public Integer stuPush(Information information) {
		UUID.randomUUID().toString();
		information.setInid(UUID.randomUUID().toString());
		String time = sdf.format(new Date());
		information.setIncreatetime(time);
		return ds.stuPush(information);
	}
	/**
	 * 获取全部
	 * @param inf
	 * @return
	 */
	@RequestMapping("/getRead")
	public List<Information> getInf(Information inf){
		System.out.println("----"+inf);
		return im.getData(inf);
	}
	
	/**
	 * 修改
	 * @param inf
	 * @return
	 */
	@RequestMapping("/updInf")
	public Integer updInf(Information inf) {
		return ds.updInf(inf);
	}
	
}
